package jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

public class JdbcDemo5 {
    public static void main(String[] args) {
        try (Connection con=DBUtil.getConnection()){
            Statement statement=con.createStatement();
            String sql="SELECT username,password,nickname,age\n" +
                    "FROM userinfo";
            ResultSet rs=statement.executeQuery(sql);
            while(rs.next()){
                String password=rs.getString("password");
                String name=rs.getString("username");
                int age=rs.getInt("age");
                String nickname=rs.getString("nickname");
                System.out.println(password+" "+name+" "+age+" "+nickname);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
